package com.zhoug.zmui.map;

import android.graphics.Path;

import java.util.ArrayList;
import java.util.List;

/**
 * 中国地图path
 *
 * @Author 35574
 * @Date 2020/9/24
 * @Description
 */
public final class ChinaPath {
    private ChinaArea area;//区域
    private Path path;//地图路径
    private int fillColor;//填充色
    private int highlightColor;//高亮填充色
    private boolean isHighlight;//是否高亮
    private int centerX;//
    private int centerY;//

    private ChinaPath(ChinaArea area, Path path) {
        this.area = area;
        this.path = path;
    }

    public ChinaArea getArea() {
        return area;
    }

    public Path getPath() {
        return path;
    }

    public void setFillColor(int fillColor) {
        this.fillColor = fillColor;
    }

    public int getFillColor() {
        return fillColor;
    }

    public int getHighlightColor() {
        return highlightColor;
    }

    public void setHighlightColor(int highlightColor) {
        this.highlightColor = highlightColor;
    }

    public boolean isHighlight() {
        return isHighlight;
    }

    public void setHighlight(boolean highlight) {
        isHighlight = highlight;
    }

    public static class Factory {

        /**
         * 获取中国的区域绘制路径
         * @return
         */
        public static List<ChinaPath> createAllPath() {
            List<ChinaPath> paths = new ArrayList<>();
            SvgPathToAndroidPath svgPathToAndroidPath = new SvgPathToAndroidPath();
            for (int i = 0; i < ChinaArea.SVGPATHS.length; i++) {
                ChinaArea chinaArea = ChinaArea.valueOf(i);
                ChinaPath chinaPath = new ChinaPath(chinaArea, svgPathToAndroidPath.parser(ChinaArea.SVGPATHS[i]));
                int centerX=0;
                int centerY=0;
                switch (chinaArea){
                    case NeiMengGu:
                        centerX=340;
                        centerY=180;
                        break;
                    case XinJiang:
                        centerX=115;
                        centerY=162;
                        break;
                    case XiZang:
                        centerX=113;
                        centerY=291;
                        break;
                    case GanSu:
                        centerX=281;
                        centerY=217;
                        break;
                    case YunNan:
                        centerX=267;
                        centerY=392;
                        break;
                    case ChongQing:
                        centerX=333;
                        centerY=321;
                        break;
                    case GuangDong:
                        centerX=405;
                        centerY=392;
                        break;
                    case ShaanXi:
                        centerX=338;
                        centerY=265;
                        break;
                    case HeBei:
                        centerX=406;
                        centerY=208;
                        break;
                    case LiaoNing:
                        centerX=468;
                        centerY=157;
                        break;
                    case HeiLongJiang:
                        centerX=503;
                        centerY=78;
                        break;
                }
                chinaPath.setCenterX(centerX);
                chinaPath.setCenterY(centerY);
                paths.add(chinaPath);
            }
            return paths;
        }

        /**
         * 获取指定区域的path
         * @param chinaArea
         * @return
         */
        public static ChinaPath create(ChinaArea chinaArea){
            SvgPathToAndroidPath svgPathToAndroidPath = new SvgPathToAndroidPath();
            return new ChinaPath(chinaArea, svgPathToAndroidPath.parser(ChinaArea.SVGPATHS[chinaArea.value]));
        }

    }

    public int getCenterX() {
        return centerX;
    }

    public void setCenterX(int centerX) {
        this.centerX = centerX;
    }

    public int getCenterY() {
        return centerY;
    }

    public void setCenterY(int centerY) {
        this.centerY = centerY;
    }
}
